home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10805 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: solon.com!not-for-mail
  2. From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 19 Mar 1996 22:29:12 -0600
  6. Organization: TU Wien
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4io1io$no4@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4iemcl$a05@solutions.solon.com>, stanr@tiac.net (Stan Ryckman) writes:
  14.  
  15. |>if (*argv[ii] == '-')
  16. |> 
  17. |> Ugh!  If I were going to mix operators that way I'd use parens.
  18. |> 
  19. |> Why not just write
  20. |>     if (argv[ii][0] == '-') ...
  21. |> and then you won't have to worry what "*argv[ii]" is?
  22.  
  23. Because you know that argv[ii][0] is really *argv[ii]?
  24.  
  25. I've used several programming languages; each had its strengths and
  26. weaknesses.  Exploiting a language's strengths gave rise to a certain
  27. programming style; doing things against the grain usually ended in
  28. cramps.  One of C's most defining attributes is the pointer concept
  29. which includes the mapping of arrays to pointer arithmetic.  If you're
  30. going to fight it, it might be better to switch to some other programming
  31. language.
  32.  
  33. I recently wrote a loop that went like this:
  34.  
  35. while (p < end_p)
  36.     ++*p++;
  37.  
  38. Maybe some will find it a counter-example; I think it's good
  39. code that embodies the way C is designed to work.  Arrays are
  40. second rate objects in C.  Use pointers.
  41.  
  42. Konrad Schwarz
  43.